// pages/bing/bing5/bing5.js
var config = require('../../../config')
var util = require('../../../utils/util.js')

Page({
	data:{
    config:{
      hospitalClass: 'three_none'
    }
  },

/**
   * 生命周期函数--监听页面跳转
   */
  jumpBtn:function(options){  
    wx.navigateTo({
      url:'../bing6/bing6'
    })
  },

  /**
   *显示页面在
   */
  showHospital:function(){
    this.setData({
      config: {
        hospitalClass: 'three_show'
      }
    })
  },

/** 
    * 上传图片接口
    */
    doUpload: function () {
        var that = this

        // 选择图片
        wx.chooseImage({
            count: 1,
            sizeType: ['compressed'],
            sourceType: ['album', 'camera'],
            success: function (res) {
                util.showBusy('正在上传')
                var filePath = res.tempFilePaths[0]
                // 上传图片
                wx.uploadFile({
                    url: config.service.uploadUrl,
                    filePath: filePath,
                    name: 'file',

                    success: function (res) {
                        util.showSuccess('上传图片成功')
                        console.log(res)
                        res = JSON.parse(res.data)
                        console.log(res)
                        that.setData({
                            imgUrl: res.data.imgUrl
                        })
                    },

                    fail: function (e) {
                        util.showModel('上传图片失败')
                    }
                })

            },
            fail: function (e) {
                console.error(e)
            }
        })
    },

    /**
     * 预览图片
     */
    previewImg: function () {
        wx.previewImage({
            current: this.data.imgUrl,
            urls: [this.data.imgUrl]
        })
    }

})